package ihm;

import java.awt.Color;
import java.awt.Component;

import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

/**
 * Créer un nouveau cell renderer pour afficher des couleurs.
 * @author Jean-François Augé
 */
public class CustomCellRenderer extends DefaultTableCellRenderer {

	private static final long serialVersionUID = 1L;

	/**
	 * Cell renderer.
	 */
	@Override
	public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
		Component cellComponent = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
		if(table.getValueAt(row, column) != null)
			if(table.getValueAt(row, column).toString().contains("dead"))
				cellComponent.setBackground(Color.RED);
		return cellComponent;
	}

}
